home *** CD-ROM | disk | FTP | other *** search
- Path: news.umbc.edu!not-for-mail
- From: schlein@umbc.edu (Jonas J. Schlein)
- Newsgroups: comp.lang.c
- Subject: Re: [Q] Porting to ANSI
- Date: 23 Jan 1996 13:03:30 -0500
- Organization: University of Maryland Baltimore County
- Message-ID: <4e37ti$6h9@umbc9.umbc.edu>
- References: <DLLu9E.91M@news.zippo.com>
- NNTP-Posting-Host: umbc9.umbc.edu
- NNTP-Posting-User: schlein
-
- John Muller <john> wrote:
- |> We are attempting to port existing code to ANSI C. However, we have
- |> many instances of something like this:
- |>
- |> typedef struct {
- |> :
- |> int len;
- |> char data[0];
- |> }
- |>
- |> Any suggestions for porting this over to ANSI?
-
- You have neglected to explain how this is actually being used, i.e. why it
- is even necessary to do such a construct. If you are doing what I think you
- are doing then using tricks with malloc() and more or less lying to the
- compiler you hope to make 'data' dynamic, yet contiguous with the rest of
- the structure. Unsurprisingly this is known as the struct hack and is
- well discussed in the FAQ. The response is long so please look it up yourself
- in question 2.6. Copies are freely available electronically via FTP at
- rtfm.mit.edu.
- --
- "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
-
- Jonas J. Schlein (schlein@gl.umbc.edu)
-